package com.lkeqi.usercenter.exception;

import com.lkeqi.usercenter.common.BaseResponse;
import com.lkeqi.usercenter.enums.ErrorCode;
import com.lkeqi.usercenter.utils.ResultUtils;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {


    @ExceptionHandler(BusinessException.class)
    public BaseResponse businessException(BusinessException e) {
        return ResultUtils.fail(e.getCode(), e.getDescription());
    }
    @ExceptionHandler(RuntimeException.class)
    public BaseResponse businessException(RuntimeException e) {
        return ResultUtils.fail(ErrorCode.SYS_ERROR);
    }
}
